# Maintainer: David Runge <dvzrv@archlinux.org>

_name=natsort
pkgname=python-natsort
pkgver=8.3.1
pkgrel=2
pkgdesc="Simple yet flexible natural sorting in Python"
arch=(any)
url="https://github.com/SethMMorton/natsort"
license=(MIT)
depends=(python python-typing-extensions)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-hypothesis python-pytest-mock)
optdepends=(
  'python-fastnumbers: more efficient sorting'
  'python-pyicu: sort in locale dependant manner'
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('98ee9bfed9307487b9ae9ced5ce723b6840c6f882d06702f205986430572b767f3ac0930ffdf0663d99256f6feed704394b2b7e11f4b01f4f0241cd8639df622')
b2sums=('3ad4d8884b463fa792f7930f6d92dda146c96cd929a58a1d418c59f8b3c5fc06329e2cf0341963c820fb8d2fc67b287ce69083a2cba9f20bd8abc06c0fca6a44')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {CHANGELOG.md,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
}
